import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-08-09
 * Time: 10:48
 */
public class Test {
    public static void main(String[] args) {
        Stack<Integer> stack = new Stack<>();
        //压栈
        stack.push(1);
        stack.push(2);
        stack.push(3);
        stack.push(4);
        //size 获取栈的长度
        int length = stack.size();
        System.out.println(length);
        //search 找元素下标
        int index = stack.search(1);
        System.out.println(index);
        //获取栈顶元素 不删除栈顶元素
        int val = stack.peek();
        System.out.println(val);
        //出栈 删除栈顶元素
        int val2 = stack.pop();
        System.out.println(val2);
        //再一次获取栈顶元素
        val = stack.peek();
        System.out.println(val);
        //清空栈
        stack.pop();
        stack.pop();
        stack.pop();
        boolean flg = stack.empty();
        System.out.println(flg);

    }
}
